from django.contrib.contenttypes.models import ContentType
from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from django.contrib.auth.models import Permission
from meiduo_admin.my_paginate import MyPageNumberPagination
from meiduo_admin.sysmanager.permission_serializser import PermissionSerializser, PermissionContentTypeSerializser


class PermissionViewSet(ModelViewSet):
    queryset = Permission.objects.all()
    serializer_class = PermissionSerializser
    pagination_class = MyPageNumberPagination


class PermissionContentTypeListView(ListAPIView):
    serializer_class = PermissionContentTypeSerializser
    queryset = ContentType.objects.all()

    # def get_queryset(self):
    #     queryset = ContentType.objects.all()
    #     for content_type in queryset:
    #         content_type.id = "%s-%s"%(content_type.id,content_type.name)
    #     return queryset